import { createApp } from 'vue'

import store from './store'
import router from './router'

// import 'normalize.css/normalize.css'

import ElementPlus from 'element-plus'
import zhCn from 'element-plus/dist/locale/zh-cn.js'
import 'element-plus/dist/index.css'
// 引入所有图标，并命名为 Icons
import * as Icons from '@element-plus/icons-vue'

import './assets/style/global.scss'

// 导入全局路由前置守卫
import './router/before_guards.js'

import App from './App.vue'

const app = createApp(App)

app.use(ElementPlus, {
  locale: zhCn,
})

// 方式一：通过遍历的方式注册所有 svg组件，会牺牲一点点性能
for (let iconName in Icons) {
  app.component(iconName, Icons[iconName])
}

// 方式二
// Object.keys(Icons).forEach((key) => {
// JS中用这行
// app.component(key, Icons[key])
// TS中用这行
// app.component(key, Icons[key as keyof typeof Icons]);
// })

app.use(router)
app.use(store)

app.mount('#app')
